﻿using ProgressTracker.Domain;
using ProgressTracker.WebUI.Models.Shared;
using System.Linq;

namespace ProgressTracker.WebUI.Translation
{
    public interface IDayModelMapper
    {
        DayModel Create(Day day);
    }

    public class DayModelMapper : IDayModelMapper
    {
        ITaskModelMapper _taskMapper;

        public DayModelMapper(ITaskModelMapper taskMapper)
        {
            _taskMapper = taskMapper;
        }

        public DayModel Create(Day day)
        {
            return new DayModel
            {
                Day = day.Date,
                Notes = day.Notes,
                TasksForDay = day.TasksForDay.Select(x => _taskMapper.Create(x, day))
            };
        }
    }
}